{% extends "cab/base.html" %}
{% block title %}{{ object.title }} - {{block.super}}{% endblock %}

{% block content %}
<h1>{{ object.title }}</h1>
{% load snippets %}
{% tags_for_object object as tags %}

<div id="snippet-info">
<dl>
<dt>Author:</dt>
<dd>{{object.author|userlink}}</dd>
<dt>Posted:</dt>
<dd>{{ object.pub_date|date:"F j, Y" }}</dd>
<dt>Language:</dt>
<dd><a href="{{ object.language.get_absolute_url }}">{{ object.language.name }}</a></dd>
<dt>Tags:</dt>
<dd>{% taglist tags "snippets_by_tag" %}</dd>


{% get_rating_for_snippet object.id as score %}
<dt>Score:</dt>
<dd>{{ score.score }} (after {{ score.num_ratings }} rating{{ score.num_ratings|pluralize }})</dd>



{% if user.is_authenticated %}
<dt>Rate this snippet:</dt>

{% if_rated user.id object.id %}
{% get_rating_by_user user.id object.id as rating %}
<dd>You rated this snippet <strong>{{ rating.get_score_display|lower }}</strong>.</dd>
{% else %}
{% url rate_snippet object.id as rate_snippet %}
<dd><a href="{{ rate_snippet }}?score=up" class="actionlink">useful</a> or 
    <a href="{{ rate_snippet }}?score=down" class="actionlink">not useful</a></dd>
{% endif_rated %}

<dt>Bookmark:</dt>
{% if_bookmarked user.id object.id %}
<dd>already bookmarked (<a href="{% url delete_bookmark bookmark.id %}">delete</a>)</dd>
{% else %}
<dd><a href="{% url add_bookmark object.id %}">Bookmark this snippet</a></dd>
{% endif_bookmarked %}

<dt>more:</dt><dd>
{% ifequal user.id object.author.id %}
<a href="{% url edit_snippet object.id %}" class="actionlink">Edit</a>
<a href="{% url delete_snippet object.id %}" class="actionlink">Delete</a>
{% endifequal %}
{% else %}
<dt>more:</dt><dd>
{% endif %}
<a href="{% url download object.id %}" type="{{ object.language.mime_type }}" 
   class="actionlink">Download</a>
</dd>
</dl>

</div>
<div id="snippet-description">
{{ object.description_html|safe }}   
</div>
<div id="snipped-code">
{{ object.highlighted_code|safe }}
</div>


{% with object as snippet %}
    {% include "comments/comments.html"%}
{% endwith %}

{% endblock %}
